<?php

class Common_Chart_Strategy_Google_Line extends Common_Chart_Strategy_Google_AxisChart {

    public function __construct() {
        parent::__construct();
    }

    public function get_chart_code() {
        return self::CHART_TYPE_LINE;
    }

    public function get_chart_type() {
        return Common_Chart::TYPE_LINE;
    }

    protected function get_colour_delimiter() {
        return ',';
    }

    protected function apply_render_options($arr_chart_parameters, $arr_data, $arr_headers, $arr_options = array()) {

        $arr_chart_parameters = parent::apply_render_options($arr_chart_parameters, $arr_data, $arr_headers, $arr_options);
        $arr_chart_parameters = $this->apply_line_options($arr_chart_parameters, $arr_data, $arr_options);

        return $arr_chart_parameters;
    }

    protected function apply_line_options($arr_chart_parameters, $arr_data, $arr_options = array()) {

        if(isset($arr_options['line_style'])) {
            $arr_line_styles = (array) $arr_options['line_style'];
            $arr_chart_parameters[self::PARAMETER_LINE_STYLE] = implode('|', $arr_line_styles);
        }

        $arr_line_styles = array();

        if(isset($arr_options['line_thickness'])) {
            $arr_series = array_keys($arr_data);
            foreach($arr_series as $str_series_key) {
                $arr_line_styles[$str_series_key] = (int) $arr_options['line_thickness'];
            }
        }

        if(!empty($arr_line_styles)) {
            $arr_chart_parameters[self::PARAMETER_LINE_STYLE] = implode('|', $arr_line_styles);
        }

        return $arr_chart_parameters;
    }

    protected function apply_thumbnail_options($arr_chart_parameters, $arr_options = array()) {

        $arr_thumbnail_parameters = parent::apply_thumbnail_options($arr_chart_parameters, $arr_options);

        $arr_thumbnail_parameters[self::PARAMETER_CHART_TYPE] = self::CHART_TYPE_LINE_SPARK;
        $arr_thumbnail_parameters[self::PARAMETER_CHART_FILL] = 'bg,s,00000000';

        return $arr_thumbnail_parameters;
    }

    public function has_feature($str_feature_key) {

        $bln = parent::has_feature($str_feature_key);

        if(!$bln) {
            switch($str_feature_key) {
            case Common_Chart::FEATURE_LINE_SIZE;
                $bln = true;
                break;
            }
        }

        return $bln;
    }

    public function get_available_chart_conversions() {
        return array(
            Common_Chart::TYPE_VERTICAL_BAR_GROUPED
        );
    }

}